package com.sdlg.controller;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.sdlg.mapper.LryMapper;
import com.sdlg.mapper.MemberMapper;
import com.sdlg.mapper.RoleMapper;
import com.sdlg.pojo.Lry;
import com.sdlg.pojo.Member;
import com.sdlg.pojo.Role;
import com.sdlg.util.Result;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;

@RestController
@RequestMapping("/role")
public class RoleController {

    @Resource
    private MemberMapper memberMapper;

    @Resource
    private LryMapper lryMapper;

    @RequestMapping("/getInfo")
    public Result getRoleInfo(Integer id,Integer role){
        if(role==2){
            LambdaQueryWrapper<Lry> wrapper=new LambdaQueryWrapper<>();
            wrapper.eq(Lry::getId,id);
            List<Lry> lries=lryMapper.selectList(wrapper);
            System.out.println(lries);
            return new Result(true,null,lries);
        }else if(role==3){
            LambdaQueryWrapper<Member> wrapper=new LambdaQueryWrapper<>();
            wrapper.eq(Member::getId,id);
            List<Member> members=memberMapper.selectList(wrapper);
            System.out.println(members);
            return new Result(true,null,members);
        }else{
            return null;
        }
    }

}